// from tstring.cc, from jason merrill, et. al.

// Copyright (C) 2000, 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING.  If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.

#include <boost/test/unit_test.hpp>
#include <xpcom/string.hpp>

#ifdef XPCOM_HAS_2BYTE_WCHAR_T

// 21.3.6.6 basic_string::find_last_not_of
BOOST_AUTO_TEST_CASE(test_rfind_3_w)
{
  typedef xpcom::wstring::size_type csize_type;
  xpcom::wstring::size_type pos;
  csize_type npos = xpcom::wstring::npos;

  xpcom::wstring x;
  pos = x.find_last_not_of(L'X');
  BOOST_CHECK( pos == npos );
  pos = x.find_last_not_of(L"XYZ");
  BOOST_CHECK( pos == npos );

  xpcom::wstring y(L"a");
  pos = y.find_last_not_of(L'X');
  BOOST_CHECK( pos == 0 );
  pos = y.find_last_not_of(L'a');
  BOOST_CHECK( pos == npos );
  pos = y.find_last_not_of(L"XYZ");
  BOOST_CHECK( pos == 0 );
  pos = y.find_last_not_of(L"a");
  BOOST_CHECK( pos == npos );

  xpcom::wstring z(L"ab");
  pos = z.find_last_not_of(L'X');
  BOOST_CHECK( pos == 1 );
  pos = z.find_last_not_of(L"XYZ");
  BOOST_CHECK( pos == 1 );
  pos = z.find_last_not_of(L'b');
  BOOST_CHECK( pos == 0 );
  pos = z.find_last_not_of(L"Xb");
  BOOST_CHECK( pos == 0 );
  pos = z.find_last_not_of(L"Xa");
  BOOST_CHECK( pos == 1 );
}

#endif
